<?php

namespace app\admin\controller;

use think\Request;
use app\admin\model\Article as mArticle;
use think\Db;

class Recycle extends Base
{


    /*页面加载
     * */
    public function index()
    {
        return $this->fetch();
    }

    /*列表数据调用
     * */
    public function lists(Request $request)
    {
        if ($request->isPost()) {
            //判断是否有条件查询
            $where = $request->has('where') ? $request->param()['where'] : [];
            //获取当前页码
            $page = $request->param('page');
            //获取每页显示条数
            $limit = $request->param('limit');
            //过滤空值项
            $where = array_filter($where);

            return mArticle::mAll($page, $limit, $where);
        } else {
            return return_json(1, '请求错误！');
        }
    }

    /*
     * 删除
     * */
    public function del(Request $request)
    {
        if ($request->isPost()) {
            $data = $request->param()['data'];
            return mArticle::mDel($data);
        } else {
            $this->error('请求参数错误', 'index/welcome');
        }
    }

    /*
     * 恢复数据
     * */
    public function restore(Request $request)
    {
        if ($request->isPost()) {
            $data = $request->param()['data'];
            return mArticle::mRestore($data);
        } else {
            $this->error('请求参数错误', 'index/welcome');
        }
    }

}
